package com.example.huadi1.utils;

import com.example.huadi1.dto.Account;

public class ThreadLoaclUtils {
    private final static ThreadLocal<Account> accountThreadLocal = new ThreadLocal<>();

    /**
     * 设置当前线程中的用户
     *
     * @param account
     */
    public static void setAccount(Account account) {
        accountThreadLocal.set(account);
    }

    /**
     * 获取线程中的用户
     *
     * @return
     */
    public static Account getAccount() {
        return accountThreadLocal.get();
    }

    /**
     * 清空线程中的用户信息
     */
    public static void clear() {
        accountThreadLocal.remove();
    }
}